﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FootBallManager : MonoBehaviour
{
    public BBInputController inputCtrl;
    public BallCtrl ball;


    private void Start()
    {
        inputCtrl = BBIPhoneTouchManager.instance.inputController();

    }

    // Update is called once per frame
    void Update()
    {
        CheckTouch();
    }

    public void CheckTouch()
    {
        if (!inputCtrl.isConnected())
        {
            Debug.Log("连接失败");
            return;
        }
        List<Vector3> touchList = new List<Vector3>();
        for (int i = 0; i < iPhoneInput.touchCount; i++)
        {
            Ray ray = Camera.main.ScreenPointToRay(iPhoneInput.GetTouch(i).position);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform != null)
                {
                    touchList.Add(hit.point);
                }
            }
        }
        BallCtrl.touches = touchList;
        ball.Check();
    }
}
